package Extend;

import java.util.Random;

public class Ex01 {
    public static void main(String[] args) {
        String name = "令狐冲,风清扬,左冷禅,岳不群,苗人凤";
        System.out.println("本班人员名单如下:");
        String[] s = name.split(",");
        for (int i = 0; i < s.length-1; i++) {//非最后,分奇偶print
            if(i % 2 == 0){
                System.out.print(s[i] + "  ");
            }else System.out.println(s[i]);
        }System.out.println(s[s.length-1]);//最后一个无论奇偶,都是换行

        Random r = new Random();
        System.out.println("被选中的同学是: "+ s[r.nextInt(s.length)]);

    }
}
